﻿<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	 <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
	<title>PHPMall {$goodsInfo.goods_name}</title>
	<meta name="keywords" content=""/>
	<meta name="description" content=""/>
	<meta name="viewport" content="width=device-width; initial-scale=1.0" />	
	<link rel="stylesheet" href="/static/index/css/base_1.css" />
	<link rel="stylesheet" href="/static/index/css/goods.css" />
	<script src="/static/index/js/jquery-2.1.4.min_1.js"></script>
	<script src="/static/index/js/jquery-migrate-1.2.1.min_1.js"></script>
	<script src="/static/layer/layer.js"></script>
	<link type="image/x-icon" href="/public/uploads/cache/images/osc1/store/index-16x16.jpg" rel="icon">
	<link type="image/x-icon" href="/public/uploads/cache/images/osc1/store/index-16x16.jpg" rel="bookmark">
</head>
<body>
	<div class="com-top-nav w">
	<div class="wcp-wrap">
	</div>
</div>
	{include file='public/header'}
<div class="wcp_wrap">
	<div class="list_crumb">
		<ul class="list_crumb_list">
			<li class="classify"><a href="/">首页</a><i class="crumb_arrow"></i></li>
					<li class="classify">
							<a  href="{:url('index/Categorys/index',array('id'=>$goodsInfo.category.id))}"  >{$goodsInfo.category.cate_name}</a>
							<i class="crumb_arrow"></i>
					</li>
			<li><a href="javascript:;">{$goodsInfo.goods_name}</a></li>
		</ul>
	</div>
	<div class="detail-ctr clearfix">
		<div class="dtl-info clearfix">
			<div class="preview">					
					<div class="smallImg">
						<div id="imageMenu">
							<ul id="images_0"  >
								{volist name="$goodsInfo.images" id="images"}
								<li data-bimg="/{$images.img_path}">
									<img width="100%" src="/{$images.img_path}" />
								</li>
								{/volist}
							</ul>
						</div>
					</div>
					<div class="bigImg" id="vertical">
						<img width="600" height="600" style= "margin-top:0px;" id="midimg" class="loading" src="" />
					</div>
			</div>
			<div class="pro-info-dtl">
				<div class="pro-detail-hd">
					<h1>
						<span class="fl">{$goodsInfo.goods_name} </span><span class="exp-style">货号：<span id="sn">{$goodsInfo.goods_code}</span></span>
					</h1>
					<a class="start-comment" href="javascript:;"></a>
				</div>
				<div class="pro-sales-list">
							<p class="pro-sales-item">
								<b class="c-red">&yen; </b><b class="current_price c-red">{$goodsInfo.shop_price}</b>
							</p>
							<p class="pro-sales-item">市场价：<span id="market-price">&yen; {$goodsInfo.markte_price}</span></p>
												
						<p class="pro-sales-item">库存量：<span id="store_quantity">{$goodsInfo.stock}</span> </p>
				
				</div>
				<!--规格-->
				<div id="selectbox" class="selectbox">
					<dl class="spec-item clearfix">
						{volist name="$goodsInfo.product" id="product"}
						<dt>{$product.name}：<span>{$product.detail}</span></dt>
						{/volist}
					</dl>
				</div>
				<!--规格-->
				<div class="sumbox">
					<div class="select_number">	
						<input type="text" onkeyup='change_quantity("{$goodsInfo.id}",this);' name="quantity" size="2" value="1" id="quantity" class="text">
						<button onclick='changeQty(1,"{$goodsInfo.id}");' class="increase">+</button>
						<button onclick='changeQty(0,"{$goodsInfo.id}");' class="decrease">-</button>
					</div>
					<div class="buttonbox">
							{if $Think.session.user}
							 <input type="button" {if $goodsInfo.stock == 0} disabled value="暂无库存" {else}  value="加入购物车"   {/if}  class="dtl-cart buy"  onclick="addCatr('{$goodsInfo.id}')">
							 <input type="button" value="立即购买" rel="buy" class="buy" style="background-color: #d00;"  ctype='p80xgpxoq1'>
							{else}
							<a href="{:url('user/login/login')}"><input type="button" value="加入购物车" class="dtl-cart buy" ></a>
							<a href="{:url('user/login/login')}"><input type="button" value="立即购买" rel="buy" class="buy" style="background-color: #d00;" ></a>
						{/if}
					</div>
				</div>
			
		</div>			
	</div>
	<div class="maybe-like">

	</div>
	<div class="pro-dtl-ctr">
				<div class="pro-dtl-menu">
					<a class="current" href="javascript:;">产品细节 <i></i></a> <a href="javascript:;" class="">商品评价 <i></i></a>
				</div>
				<div class="detail-box" style="display: block;">
					<?php echo $goodsInfo['goods_des'];?>
				</div>
	</div>
</div>
</div>
	<!--底部-->
	{include file='public/footer'}
<script>
 var navtoTop = $(".nav").offset().top + $(".nav").height();
    var topNavTop = $(".nav").offset().top;
    $(".right-sidebar").css('top', topNavTop + 'px');
    $(".go-to-top").fadeOut(100);

    $(window).scroll(function() {
        var scrollHeight = $(window).scrollTop();
        if (scrollHeight <= navtoTop) {
            $(".right-sidebar").css('top', topNavTop + 'px');
            $(".nav").removeClass("fixed-nav");
            $(".go-to-top").fadeOut(100);
            $(".right-sidebar .account-box").css('bottom', topNavTop + 'px');
            $(".sidebar-box .like-show-more,.sidebar-box .saw-show-more").css('margin-bottom', topNavTop * 2 + 'px');
        } else if (scrollHeight > navtoTop) {
            $(".right-sidebar").css('top', '0px');
            $(".nav").addClass("fixed-nav");
            $(".go-to-top").fadeIn(100);
            $(".right-sidebar .account-box").css('bottom', '0');
            $(".all-styles-tab").hide();

            $(".fixed-nav .main-nav .all-styles").hover(function() {
                $(this).find(".all-styles-tab").show();
            },
            function() {
                $(this).find(".all-styles-tab").hide();
            });
            $(".sidebar-box .like-show-more,.sidebar-box .saw-show-more").css('margin-bottom', topNavTop + 'px');
        }
    });

</script>
<script>
 // 更改数量
 function changeQty(num,goods_id) {
     // 获取现有的数量
	 var quantity = $("#quantity").val();
	 if (num === 0){
       	if(quantity == 1 || quantity < 1){
            layer.alert('最小起订量是1 件');
            $("#quantity").val(1);

            return ;
		}else {
             $("#quantity").val(quantity-1);
		}
	 }else {
	      // 通过ajax请求 查询商品库存。
         $.ajax({
             url:"{:url('index/Goods/getGoodsStock')}",
             type:"POST",
             dataType:"json",
             data:{
                 goods_id:goods_id
             },
             success:function (res) {
				if(quantity >= res){
					layer.alert('该商品数量不足，剩余 '+ res+' 件')
                    $("#quantity").val(res);
				}else {
                    $("#quantity").val(parseInt(quantity) + 1);
                }
             }
         });

     }
 }
 function change_quantity(goods_id,obj) {
     var quantity = $(obj).val();
     if(quantity<1){
         $("#quantity").val(1);
	 }
	 if(isNaN(quantity)){
         $("#quantity").val(1);
	 }
     // 通过ajax请求 查询商品库存。
     $.ajax({
         url:"{:url('index/Goods/getGoodsStock')}",
         type:"POST",
         dataType:"json",
         data:{
             goods_id:goods_id
         },
         success:function (res) {
             if(quantity > res){
                 layer.alert('该商品数量不足，剩余 '+ res+' 件')
                 $("#quantity").val(res);
             }
         }
     });
 }

 // 加入购物车
 function addCatr(goods_id) {
     var quantity = $("#quantity").val();  // 商品数量
     $.ajax({
         url:"{:url('user/Cart/addCart')}",
         type:"POST",
         dataType:"json",
         data:{
             goods_id:goods_id,
             quantity:quantity
         },
         success:function (res) {
             if(res.code === -1){
                 $("#quantity").val(1);
                 return layer.alert(res.msg)
             }else if(res.code === 1) {
                 $("#quantity").val(1);
                 $(".cart-num").html(res.count);
                 return layer.alert(res.msg)
			 }
         }
     });
 }

var cur_action=null;
var last_action=null;
var flag=0;
//滑动动画
function right_sidebar_animate(id){
	
	cur_action=id;
	
	if(cur_action==id&&flag==0){	
		 last_action=id;		 
		 $('.right-sidebar').animate({right: "0px"},600);
         $('.sidebar-box-item').addClass("hide");
         $('#'+id).removeClass("hide");
         flag=1
	}else if(cur_action==last_action&&flag==1){
		$('.right-sidebar').animate({right: "-280px"},'fast');
		cur_action=null;
		last_action=null;
		flag=0;		
		return;
	}else if(last_action!=cur_action){		
		flag=1;	
		last_action=id;		
		$('.sidebar-box-item').addClass("hide");
        $('#'+id).removeClass("hide");			
	}
}
//关闭右边栏菜单
$('.sidebar-box-close').click(function(){
	cur_action=null;
	last_action=null;
	flag=0;	
	$('.right-sidebar').animate({right: "-280px"},'fast');	
});



//回到顶部
$(".go-to-top").click(function() {
			$('body,html').animate({
				scrollTop: 0
			},
			"fast");
			return false;
	}); 	
</script>

<script src="/static/index/js/common_1.js"></script>

<script src="/static/index/js/jquery.raty.min.js"></script>
<script>



$(function(){
	$('#imageMenu ul:first li:first').trigger('click');
});
//图册缩略图点击
$('#imageMenu li').click(function(){
	$('#imageMenu li').removeClass('click');
	$(this).addClass('click');
	var src=$(this).attr('data-bimg');
	$("#midimg").attr("src", src);
});




</script>

</html>